package com.xszx.business.controller.web;

import com.xszx.server.dto.AjaxJson;
import com.xszx.server.dto.Page;
import com.xszx.server.entity.MemberCourse;
import com.xszx.server.service.MemberCourseService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/web/memberCourse")
public class MemberCourseController {
    @Resource
    private MemberCourseService memberCourseService;

    @GetMapping("/getMemberCourse")
    public AjaxJson getMemberCourse(String id){
        return AjaxJson.success().put("memberCourses",memberCourseService.getMemberCourse(id));
    }

    @PostMapping("/enroll")
    public AjaxJson enroll(@RequestBody MemberCourse memberCourse){
        return AjaxJson.success().put("memberCourse",memberCourseService.enroll(memberCourse));
    }

    @PostMapping("/get-enroll")
    public AjaxJson getEnroll(@RequestBody MemberCourse memberCourse){
        return AjaxJson.success().put("memberCourse",memberCourseService.getEnroll(memberCourse));
    }
    @GetMapping("/deleteMemberCourse")
    public AjaxJson deleteMemberCourse(String id){
        int result = memberCourseService.del(id);
        if(result>0){
            return AjaxJson.success("删除成功");
        }else{
            return AjaxJson.error("删除失败");
        }
    }
}
